package org.evolAI.organism.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * 
 * This class is used to store attributes of a memory.  The weight property assigns a numerical
 * value to a memory representing how strong the memory is while the date properties track how 
 * recently a memory was created and/or updated  
 * 
 * @author whull
 *
 */
@Entity
@Table(name="Memory")
@XmlRootElement
public class Memory {

	private long id;
	private int weight;
	private Date created;
	private Date updated;
	
	public Memory() {
		this.weight = 1;
		this.created = new Date();
		this.updated = new Date();
	}
	
	protected Memory(Memory memory) {
		this.weight= memory.weight;
		this.created = new Date(memory.created.getTime());
		this.updated = new Date(memory.updated.getTime());
	}
	
	public Memory copy() {
		return new Memory(this);
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "step_id")
	public long getId() {
		return this.id;
	}
	
	public void setId(long id) {
		this.id = id;
	}

	@Column(name = "weight")
	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	@Column(name = "created")
	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		
	}

	@Column(name = "updated")
	public Date getUpdated() {
		return updated;
	}

	public void setUpdated(Date updated) {
		this.updated = updated;
	}

}
